/**
 * IBatisSqlMapCofigEditor.java : [com.ibader.eclipse.editors] Created on 2009. 5. 17.
 *
 * Copyright (c) 2009 Raccoon Project Team.
 * Seoul, Korea
 * All rights reserved.
 *
 */
package com.ibader.eclipse.editors;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.forms.editor.FormEditor;

import com.ibader.eclipse.Activator;
import com.ibader.eclipse.editors.sqlmap.SqlMapAliasMapPage;
import com.ibader.eclipse.editors.sqlmap.SqlMapOverviewPage;
import com.ibader.eclipse.editors.sqlmap.SqlMapQueryPage;

/**
 * @author KimJungSu
 * @version
 */
public class SqlMapEditor extends FormEditor {

	// define page constant
	public static final int PAGE_OVERVIEW = 0;
	public static final int PAGE_QUERY = 1;
	public static final int PAGE_ALIAS_MAP = 2;
	public static final int PAGE_XML = 3;

	// define form page
	private SqlMapOverviewPage overviewPage;
	private SqlMapQueryPage queryPage;
	private SqlMapAliasMapPage aliasMapPage;
	private XMLEditor xmlPage;


	public SqlMapEditor() {
		super();
		// TODO Auto-generated constructor stub
	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub
		Activator.log("+++SqlMapEditor::dispose");
		super.dispose();
		Activator.log("---SqlMapEditor::dispose");
	}

	@Override
	public void init(IEditorSite site, IEditorInput input)
			throws PartInitException {
		// TODO Auto-generated method stub
		Activator.log("+++SqlMapEditor::init");
		super.init(site, input);
		Activator.log("---SqlMapEditor::init");
	}

	@Override
	public boolean isDirty() {
		// TODO Auto-generated method stub
		return super.isDirty();
	}

	@Override
	public void removePage(int pageIndex) {
		// TODO Auto-generated method stub
		super.removePage(pageIndex);
	}

	@Override
	public void setFocus() {
		// TODO Auto-generated method stub
		Activator.log("+++SqlMapEditor::setFocus");

		switch (getActivePage()) {
		case PAGE_OVERVIEW:
			break;

		case PAGE_QUERY:
			break;

		case PAGE_ALIAS_MAP:
			break;

		case PAGE_XML:
			break;

		default:
			break;
		}

		Activator.log("---SqlMapEditor::setFocus");
	}

	@Override
	public void doSave(IProgressMonitor monitor) {
		// TODO Auto-generated method stub
		Activator.log("+++SqlMapEditor::doSave");
		Activator.log("---SqlMapEditor::doSave");
	}

	@Override
	public void doSaveAs() {
		// TODO Auto-generated method stub
		Activator.log("+++SqlMapEditor::doSaveAs");
		Activator.log("---SqlMapEditor::doSaveAs");
	}

	@Override
	public boolean isSaveAsAllowed() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	protected void addPages() {
		// TODO Auto-generated method stub
		Activator.log("+++SqlMapEditor::addPages");

		try {
			overviewPage = new SqlMapOverviewPage(this, "SqlMapOverview", "Overview");
			addPage(overviewPage);

			queryPage = new SqlMapQueryPage(this, "SqlMapQueryPage", "Query");
			addPage(queryPage);

			aliasMapPage = new SqlMapAliasMapPage(this, "SqlMapAliasMapPage", "Alias/Map");
			addPage(aliasMapPage);

			xmlPage = new XMLEditor(this);
			setPageText(addPage(xmlPage, this.getEditorInput()), "xml");

		} catch (PartInitException e) {
			// TODO Auto-generated catch block
		}

		Activator.log("---SqlMapEditor::addPages");
	}

	@Override
	public void editorDirtyStateChanged() {
		// TODO Auto-generated method stub
		super.editorDirtyStateChanged();
	}


}
